package com.foreknow.demo5;

import java.util.Arrays;

public class Ex2 {
    public static void main(String[] args) {
        int[] array = {1, 2, 2, 3, 4, 4, 5};

        // 对数组进行排序
        Arrays.sort(array);

        for (int i = 1; i < array.length; i++) {
            if (array[i] == array[i - 1]) {
                array[i] = 0;
            }
        }

        // 输出结果数组
        System.out.println("去重后的数组：");
        for (int value : array) {
            System.out.print(value + " ");
        }
    }
}
